package com.nikitova.craps3d.view.components.game3d 
{
	import jiglib.geometry.JBox;
	import jiglib.math.JMatrix3D;
	import jiglib.math.JNumber3D;
	import jiglib.physics.RigidBody;
	import jiglib.plugin.papervision3d.Papervision3DPhysics;
	import jiglib.plugin.papervision3d.Pv3dMesh;

	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.objects.special.commands.MoveTo;
	import org.papervision3d.view.layer.ViewportLayer;

	/**
	 * @author schranz
	 */
	public class TableBorder3D
	{
		private var __table            : RigidBody;
		private var __physics          : Papervision3DPhysics;
		private var __viewportLayer    : ViewportLayer;
		private var __light            : PointLight3D;
		private var __width 		      : Number;
		private var __height    		  : Number;
		private var __depth 		      : Number;
		private var __model			  : DAE;



		public function TableBorder3D(vpl : ViewportLayer, physics : Papervision3DPhysics, light : PointLight3D, model:DAE, width:Number, depth:Number, height:Number):void 
		{
			__viewportLayer = vpl;	
			__physics 		= physics;
			__light 		= light;
			__width 		= width;
			__depth 		= depth;
			__height		= height;
			__model 		= model;
			
		}

		private function createTableRigidBody() : JBox
		{
			var tableBox:JBox = new JBox(new Pv3dMesh(__model), __width, __depth, __height);
			tableBox.rotationY = 90;
			tableBox.moveTo( new JNumber3D(0, -14, 15));
			__viewportLayer.addDisplayObject3D(__model);
            __physics.addBody(tableBox);
			return tableBox;
		}
		public function createTable() : void
		{
			__model.scaleZ = 1.2;
			__model.scaleX = 1.02;
			__table = createTableRigidBody();
			__table.movable = false;   
		}

		public function get rigidBody() : RigidBody 
		{
			return __table;
		}
		
		public function get model() : DAE 
		{
			return __model;
		}
		
		public function get layerIndex() : Number
		{
			return __viewportLayer.layerIndex;
		}
		
		public function get width() : Number
		{
			return __width;
		}
		
		public function get depth() : Number
		{
			return __depth;
		}

		public function get height() : Number
		{
			return __height;
		}

	
	}
}
